﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Rbac.Read.APi.Application.Command.Rules;
using T_Rbac_Demain;

namespace T_Rbac.Read.APi.Controllers
{
    /// <summary>
    /// 角色
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RuleReadController : ControllerBase
    {
        private readonly IMediator mediator;

        public RuleReadController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 通过主键获取单条数据
        /// </summary>
        /// <param name="rulesFindCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Rule> GetRuleByid([FromQuery]RulesFindCommand rulesFindCommand)
        {
            return await mediator.Send(rulesFindCommand);
        }
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <param name="ruleReadAllCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IQueryable<Rule>> GetRulesAllValues([FromQuery]RuleReadAllCommand ruleReadAllCommand)
        {
            return await mediator.Send(ruleReadAllCommand);
        }
        /// <summary>
        /// 分页,显示查询
        /// </summary>
        /// <param name="ruleSearchCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Rule>> GetPageresultRule([FromQuery]RuleSearchCommand ruleSearchCommand)
        {
            return await mediator.Send(ruleSearchCommand);
        }
        /// <summary>
        /// 获取在该部门下的员工
        /// </summary>
        /// <param name="ruleSearchByDnameCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IQueryable<Rule>> GetRuleWords([FromQuery]RuleSearchByDnameCommand ruleSearchByDnameCommand)
        {
            return await mediator.Send(ruleSearchByDnameCommand);
        }

    }
}
